﻿using Demo_test.Models.DKTV;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Demo_test.Controllers
{
    public class ThanhVienController : Controller
    {
        // GET: ThanhVien
        Model1 db = new Model1();
        public ActionResult Index()
        {
           
            var a = db.Usernames;
            return View(a);           
        }
       
        [HttpGet]
        public ActionResult Insert()
        {
            return View(new Username());
        }
        [HttpPost]
        public ActionResult Insert(Username model)
        {

            try
            {
                db.Usernames.Add(model);
                db.SaveChanges();
                ModelState.AddModelError("", "Cập nhật thành công !");
                return RedirectToAction("Index");
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);

                return View("Index", model);

            }

        }
    }
}